<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ taglib prefix="s" uri="/struts-tags"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<script type="text/javascript" src="scripts/vendor/jquery.form.js"></script>
<script charset="utf-8" src="scripts/vendor/kindeditor/kindeditor-min.js"></script>
<script charset="utf-8" src="scripts/vendor/kindeditor/lang/zh_CN.js"></script>

<script type="text/javascript">
	//在线编辑器

	var editor;
	KindEditor.ready(function(K) {
		editor = K.create('#homework', {
			uploadJson : 'file/file-upload.action',
			fileManagerJson : 'file/file-manager.action',
			allowImageUpload : true,
			filterMode : true,
			width : '700px',
			items : [ 'fontname', 'fontsize', '|', 'forecolor', 'hilitecolor',
					'bold', 'italic', 'underline', 'removeformat', '|',
					'justifyleft', 'justifycenter', 'justifyright',
					'insertorderedlist', 'insertunorderedlist', '|',
					'emoticons', 'image', 'link' ]
		});
	});
	
	function save(status){
		$('#status').val(status);
		editor.sync();
		$('#hand_form').submit(function(){
			$(this).ajaxSubmit(function(json){
				if(json.success){
					window.location = "course/timetable-view.action?tid=${param.tid}";
				}else{
					alert("数据上传失败");
				}
			});
			return false;
		});
		$('#hand_form').trigger('submit');
	}

</script>


<title><s:property value="handin.homework.timeTable.content.title" />的作业</title>
</head>
<body>
	<div class="row">

		<!-- 作业内容 -->
		<div class="span12">
			<div class="clearfix alert alert-info">
				<div>
					<h3>
						<s:property value="handin.homework.timeTable.content.title" />
					</h3>
					<s:property value="handin.homework.timeTable.course.name" />
					<s:date name="handin.homework.timeTable.teachDate" format="yyyy-MM-dd" />
					作业
				</div>
			</div>
			<div class="clearfix">
				<s:property value="handin.homework.content" escape="false" />
				<hr />
			</div>
		</div>

		<!-- 上交的 -->
		<div class="span12">
			<form id="hand_form" action="course/commit-handin.action">
				<p>
					<textarea id="homework" name="handin.content"><s:property value="handin.content"/></textarea>
				</p>
				<input name="handin.version" value="<s:property value='handin.version'/>" type="hidden" />
				<input name="handin.id" value="<s:property value='handin.id'/>" type="hidden" />
				<input id="status" name="handin.status" value="" type="hidden"/>
				<input name="haid" value="<s:property value='handin.homework.id'/>" type="hidden"/>
			</form>
			<button id="hand_btn" onclick="save('<s:property value="@org.projects.graduates.domain.ContentStatus@ARTWORK"/>')" class="btn">交作业</button>
			<a onclick="save('<s:property value="@org.projects.graduates.domain.ContentStatus@DRAFT"/>')" href="javascript:void(0);" >存为草稿</a>
		</div>

	</div>
</body>
</html>